﻿''' <summary>Generic Instant Message schema</summary>
Public Class IM
    Inherits Indexable


    Public Sub New(ByVal content As String, ByVal format As IndexFormats, ByVal messagetime As Date, ByVal buddyname As String)
        MyBase.New(content, format)
        Me._message_time = messagetime
        Me._buddy_name = buddyname
    End Sub


    ''' <summary>Time the instant message was received </summary>
    ''' <remarks> required  </remarks>
    Private _message_time As Date
    ''' <summary>Name of the other person in the conversation </summary>
    ''' <remarks> required  </remarks>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _buddy_name As String




    ''' <summary>Name of the user (myself) </summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _user_name As String


    ''' <summary>Title associated with the instant message(s) </summary>
    <MarshalAs(UnmanagedType.BStr)> _
    Private _title As String
    ''' <summary>Identifier hint to group messages from the same conversation </summary>
    <MarshalAs(UnmanagedType.U4)> _
    Private _conversation_id As Integer




    ''' <summary>Name of the other person in the conversation </summary>
    ''' <remarks> required  </remarks>
    Public ReadOnly Property Buddy_name() As String
        Get
            Return _buddy_name
        End Get
    End Property
    ''' <summary>Identifier hint to group messages from the same conversation </summary>
    Public Property Conversation_id() As Integer
        Get
            Return _conversation_id
        End Get
        Set(ByVal value As Integer)
            _conversation_id = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>Time the instant message was received </summary>
    ''' <remarks> required  </remarks>
    Public ReadOnly Property Message_time() As Date
        Get
            Return _message_time
        End Get
    End Property
    ''' <summary>Title associated with the instant message(s) </summary>
    Public Property Title() As String
        Get
            Return _title
        End Get
        Set(ByVal value As String)
            _title = value
            SetOtherPropertiesFlag()
        End Set
    End Property
    ''' <summary>Name of the user (myself) </summary>
    Public Property User_name() As String
        Get
            Return _user_name
        End Get
        Set(ByVal value As String)
            _user_name = value
            SetOtherPropertiesFlag()
        End Set
    End Property


    Protected Overrides Sub AddRequredProperties(ByVal e As [Event])
        MyBase.AddRequredProperties(e)

        e.AddProperty("message_time", Me._message_time.ToOADate)
        e.AddProperty("buddy_name", Me._buddy_name)

    End Sub

    Protected Overrides Sub AddOtherProperties(ByVal e As [Event])
        MyBase.AddOtherProperties(e)


        If Not String.IsNullOrEmpty(_user_name) Then e.AddProperty("user_name", _user_name)
        If Not String.IsNullOrEmpty(_title) Then e.AddProperty("title", _title)

        e.AddProperty("conversation_id", Me._conversation_id)



    End Sub



    
End Class